package com.aya.aop.custom.intro.advisor;

import com.aya.aop.custom.intro.IntroAnnotation;
import com.aya.aop.custom.intro.MyIntroductionInterceptor;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.stereotype.Service;

@Service
public class IntroAnnotationAdvisor extends DefaultIntroductionAdvisor {
    public IntroAnnotationAdvisor(MyIntroductionInterceptor introductionInterceptor) {
        super(introductionInterceptor);
    }
    /**
     * 匹配规则。
     * 或者写死类型都行
     *
     * @param clazz
     * @return
     */
    @Override
    public boolean matches(Class<?> clazz) {

       return AnnotatedElementUtils.hasAnnotation(clazz, IntroAnnotation.class);
    }
}
